
import { createStore, applyMiddleware, combineReducers } from "redux";
//applyMiddleware 调用中间件

//引入reducer
import countReducer from "./reducers/countreducer";
import movieReducer from './reducers/moviereducer'

//引入redux-thunk
import thunk from 'redux-thunk'
//异步处理中间件
//当我们要进行异步action，action是一个函数，我们dispacth的函数就会提交到中间件
//中间件帮我们执行函数，一般函数中会有一个dispatch再次派发到store中

//使用redux提供的combineReducers方法 合并多个reducer
const allReducer = combineReducers({
  count: countReducer,
  movie: movieReducer
})

//关联countReducer //第二个参数调用中间件
const store = createStore(allReducer, applyMiddleware(thunk)) //创建包含指定reducer的store对象

export default store //暴露store对象